﻿/*
----------------------------------------
    Rodeo Game Engine

    Rodeo Entity Module
    Mesh.h - header file

    Copyright(c) Marcin Goryca
----------------------------------------
*/
#ifndef RODEO_ENTITY_MESH_H_
#define RODEO_ENTITY_MESH_H_

#ifndef RODEO_MATH_VECTOR2_H_
#include "math\vector2.h"
#endif

#ifndef RODEO_PRIMITIVE_GEOMETRYTOOLS_H_
#include "primitive\geometrytools.h"
#endif    //RODEO_PRIMITIVE_GEOMETRYTOOLS_H_

namespace rodeoentity
{
struct MeshVertex;
struct MeshTriangle;
struct MeshUV;
struct MeshNormal;

struct Mesh
{
    std::vector<MeshTriangle*> triangles_;
    std::vector<MeshUV*> coordinates_;
    std::vector<rodeomath::Vector3> normals_;
    std::vector<rodeomath::Vector3> vertex_normals_;
    std::vector<rodeomath::Vector3> surface_normals_;

    MeshVertex* vertex_;
    MeshTriangle* triangle_;
    MeshUV* coordinate_;
    MeshNormal* normal_;
    rodeocore::us index_;
    rodeocore::ui vertex_count_;
    rodeocore::ui face_count_;
    rodeocore::ui uv_count_;
    rodeocore::ui normal_count_;
    rodeocore::ui vertex_normal_count_;
    rodeocore::ui surface_normal_count_;
    char meshname_[255];
    const char* mesh_name_;
    int material_id_;
    bool has_texture_;

    void reset();
    void clear();
    void init();
    void generateNormals();
    void generateVertexNormals();
    void generateSurfaceNormals();
};

// MeshVertex
struct MeshVertex
{
    rodeomath::Vector3 vertex_;
};


// MeshTriangle
struct MeshTriangle
{
    rodeocore::us triangle_[3];
};

// MeshUV
struct MeshUV
{
    rodeomath::Vector2 uv_;
};

// MeshNormal
struct MeshNormal
{
    rodeomath::Vector3 normal_;
};


// MeshMaterial
struct MeshMaterial
{
    char name_[255];
    char file_[255];
    BYTE color_[3];
    rodeocore::ui id_;
};
}    //end of rodeoentity namespace
#endif    //RODEO_SCENE_MESH_H_